package com.ecoolex.chinadutyfree.retailer.ws;

import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import com.ecoolex.chinadutyfree.retailer.core.manager.DirectMailGoodsDummyManager;
import com.ecoolex.chinadutyfree.retailer.core.manager.DirectMailGoodsManager;
import com.ecoolex.chinadutyfree.retailer.core.manager.DirectMailGoodsOrderAfterSalesManager;
import com.ecoolex.chinadutyfree.retailer.core.manager.DirectMailGoodsOrderAfterSalesRecordManager;
import com.ecoolex.chinadutyfree.retailer.core.manager.DirectMailGoodsOrderCouponManager;
import com.ecoolex.chinadutyfree.retailer.core.manager.DirectMailGoodsOrderDetailManager;
import com.ecoolex.chinadutyfree.retailer.core.manager.DirectMailGoodsOrderIdentityManager;
import com.ecoolex.chinadutyfree.retailer.core.manager.DirectMailGoodsOrderManager;
import com.ecoolex.chinadutyfree.retailer.core.manager.DirectMailGoodsOrderReceiverManager;
import com.ecoolex.chinadutyfree.retailer.core.manager.DirectMailGoodsOrderSenderManager;
import com.ecoolex.chinadutyfree.retailer.core.manager.DirectMailGoodsOrderShippedRecordManager;
import com.ecoolex.chinadutyfree.retailer.entity.DirectMailGoodsOrder;
import com.ecoolex.chinadutyfree.retailer.entity.DirectMailGoodsOrderAfterSales;
import com.ecoolex.chinadutyfree.retailer.entity.DirectMailGoodsOrderAfterSalesRecord;
import com.ecoolex.chinadutyfree.retailer.entity.DirectMailGoodsOrderCoupon;
import com.ecoolex.chinadutyfree.retailer.entity.DirectMailGoodsOrderDetail;
import com.ecoolex.chinadutyfree.retailer.entity.DirectMailGoodsOrderIdentity;
import com.ecoolex.chinadutyfree.retailer.entity.DirectMailGoodsOrderReceiver;
import com.ecoolex.chinadutyfree.retailer.entity.DirectMailGoodsOrderSender;
import com.ecoolex.chinadutyfree.retailer.entity.DirectMailGoodsOrderShippedRecord;
import com.ecoolex.chinadutyfree.retailer.enums.DirectMailGoodsOrderStatus;
import com.ecoolex.chinadutyfree.retailer.pojo.DirectMailGoodsOrderChannelDTO;
import com.ecoolex.chinadutyfree.retailer.pojo.PreDirectMailGoodsOrderDTO;
import com.ecoolex.chinadutyfree.retailer.pojo.PreSubmitDirectMailGoodsOrderDTO;
import com.ecoolex.chinadutyfree.retailer.pojo.QueryDirectMailGoodsOrderAfterSalesDTO;
import com.ecoolex.chinadutyfree.retailer.pojo.QueryDirectMailGoodsOrderDTO;
import com.ecoolex.chinadutyfree.retailer.pojo.SubmitDirectMailGoodsOrderDTO;
import com.ecoolex.framework.common.exception.BizException;
import com.ecoolex.framework.common.pojo.Page;
import com.ecoolex.framework.common.pojo.Pagination;
import com.ecoolex.framework.common.pojo.Sorting;

import java.util.List;

@Service
public class DirectMailGoodsOrderServiceImpl implements DirectMailGoodsOrderService{
	
	@Autowired
	private DirectMailGoodsOrderManager directMailGoodsOrderManager;

	@Autowired
	private DirectMailGoodsManager directMailGoodsManager;

	@Autowired
	private DirectMailGoodsDummyManager directMailGoodsDummyManager;

	@Autowired
	private DirectMailGoodsOrderShippedRecordManager directMailGoodsOrderShippedRecordManager;

	@Autowired
	private DirectMailGoodsOrderSenderManager orderSenderManager;

	@Override
	public DirectMailGoodsOrder getByOrderId(Integer orderId) {
		return directMailGoodsOrderManager.getByOrderId(orderId);
	}

	@Override
	public DirectMailGoodsOrder refund(DirectMailGoodsOrder order, String reason, String updateUser){
		return directMailGoodsOrderManager.refund(order, reason, updateUser);
	}
	
	@Override
	public DirectMailGoodsOrderAfterSales confirmRefund(DirectMailGoodsOrderAfterSales afterSales, String updateUser) throws BizException {
		return directMailGoodsOrderManager.confirmRefund(afterSales, updateUser);
	}

	@Override
	public DirectMailGoodsOrderAfterSales refuseRefund(DirectMailGoodsOrderAfterSales afterSales,String auditOpinion, String updateUser) throws BizException {
		return directMailGoodsOrderManager.refuseRefund(afterSales,auditOpinion, updateUser);
	}
	
	@Override
	public DirectMailGoodsOrderAfterSales confirmReturn(DirectMailGoodsOrderAfterSales afterSales, String updateUser) throws BizException {
		return directMailGoodsOrderManager.confirmReturn(afterSales, updateUser);
	}

	@Override
	public DirectMailGoodsOrderAfterSales refuseReturn(DirectMailGoodsOrderAfterSales afterSales, String auditOpinion, String updateUser) throws BizException {
		return directMailGoodsOrderManager.refuseReturn(afterSales, auditOpinion, updateUser);
	}
	
	@Override
	public DirectMailGoodsOrderAfterSales confirmExchange(DirectMailGoodsOrderAfterSales afterSales, String updateUser) throws BizException {
		return directMailGoodsOrderManager.confirmExchange(afterSales, updateUser);
	}

	@Override
	public DirectMailGoodsOrderAfterSales refuseExchange(DirectMailGoodsOrderAfterSales afterSales, String auditOpinion, String updateUser) throws BizException {
		return directMailGoodsOrderManager.refuseExchange(afterSales, auditOpinion, updateUser);
	}
	
	@Override
	public DirectMailGoodsOrderAfterSales confirmReceipt(DirectMailGoodsOrderAfterSales afterSales, String updateUser) throws BizException {
		return directMailGoodsOrderManager.confirmReceipt(afterSales, updateUser);
	}
	
	@Override
	public DirectMailGoodsOrderAfterSales refuseReceipt(DirectMailGoodsOrderAfterSales afterSales, String reason, String updateUser) throws BizException {
		return directMailGoodsOrderManager.refuseReceipt(afterSales, reason, updateUser);
	}

	@Override
	public DirectMailGoodsOrder getOrderPossibleBeDeletedById(Integer orderId) {
		return directMailGoodsOrderManager.getPossibleBeDeletedById(orderId);
	}

	@Override
	public Pagination<DirectMailGoodsOrder> query(QueryDirectMailGoodsOrderDTO query, Sorting[] sorts, Page page) {
		return directMailGoodsOrderManager.query(query, sorts, page);
	}

	@Override
	public DirectMailGoodsOrder applyRefund(DirectMailGoodsOrder order,String reason,String evidenceImage, String updateUser) throws BizException {
		return directMailGoodsOrderManager.applyRefund(order,reason,evidenceImage, updateUser);
	}
	
	@Override
	public DirectMailGoodsOrder applyReturn(DirectMailGoodsOrder order, String reason, String evidenceImage, String updateUser) throws BizException {
		return directMailGoodsOrderManager.applyReturn(order, reason, evidenceImage, updateUser);
	}

	@Override
	public DirectMailGoodsOrder applyExchange(DirectMailGoodsOrder order, String reason, String evidenceImage, String updateUser) throws BizException {
		return directMailGoodsOrderManager.applyExchange(order, reason, evidenceImage, updateUser);
	}
	
	@Override
	public DirectMailGoodsOrderAfterSales cancelAfterSales(DirectMailGoodsOrderAfterSales afterSales, String updateUser) throws BizException {
		return directMailGoodsOrderManager.cancelAfterSales(afterSales, updateUser);
	}

	@Override
	public DirectMailGoodsOrder submitOrder(SubmitDirectMailGoodsOrderDTO submit, DirectMailGoodsOrderIdentity identity, DirectMailGoodsOrderChannelDTO channel, String createUser) {
		return directMailGoodsOrderManager.submit(submit, identity, channel, createUser);
	}

	@Override
	public PreDirectMailGoodsOrderDTO preSubmitOrder(PreSubmitDirectMailGoodsOrderDTO submit) {
		return directMailGoodsOrderManager.preComputingCost(submit);
	}

	@Override
	public void deleteOrder(DirectMailGoodsOrder order, String updateUser) {
		directMailGoodsOrderManager.delete(order, updateUser);
	}

	@Override
	public DirectMailGoodsOrder cancel(DirectMailGoodsOrder order, String updateUser) {
		return directMailGoodsOrderManager.cancel(order, updateUser);
	}

	// @Override
	// public DirectMailGoodsOrder completeInfo(DirectMailGoodsOrder order, DirectMailGoodsOrderIdentity identity,
	// String updateUser) {
	// return orderManager.completeInfo(order, identity, updateUser);
	// }


	@Override
	public DirectMailGoodsOrder shipped(DirectMailGoodsOrder order, String updateUser) {
		return directMailGoodsOrderManager.shipped(order, updateUser);
	}

	@Override
	public DirectMailGoodsOrder confirmReceipt(DirectMailGoodsOrder order, String updateUser) {
		return directMailGoodsOrderManager.confirmReceipt(order, updateUser);
	}

	@Override
	public DirectMailGoodsOrder getOrderByIdAndUserId(Integer orderId, Integer userId) {
		return directMailGoodsOrderManager.getByIdAndUserId(orderId, userId);
	}

	@Override
	public DirectMailGoodsOrder getOrderByNoAndUserId(String orderNo, Integer userId){
		return directMailGoodsOrderManager.getByNoAndUserId(orderNo, userId);
	}

	@Override
	public DirectMailGoodsOrder getOrderById(Integer orderId) {
		return directMailGoodsOrderManager.getById(orderId);
	}

	@Override
	public Pagination<DirectMailGoodsOrder> queryUserData(Integer userId, List<String> status, Sorting[] sorts, Page page) {
		return directMailGoodsOrderManager.queryUserData(userId, status, sorts, page);
	}

	@Override
	public Long countTotalNumberByStatus(Integer userId, DirectMailGoodsOrderStatus status) {
		return directMailGoodsOrderManager.countTotalNumberByStatus(userId, status);
	}

	@Override
	public Long countTotalNumberByStatus(Integer userId, List<DirectMailGoodsOrderStatus> status) {
		return directMailGoodsOrderManager.countTotalNumberByStatus(userId, status);
	}

	@Autowired
	private DirectMailGoodsOrderDetailManager orderDetailManager;

	@Override
	public List<DirectMailGoodsOrderDetail> queryOrderDetailByOrderId(Integer orderId) {
		return orderDetailManager.queryByOrderId(orderId);
	}
	
	@Override
	public List<DirectMailGoodsOrderDetail> queryOrderDetailPossibleBeDeleted(Integer orderId){
		return orderDetailManager.queryOrderDetailPossibleBeDeleted(orderId);
	}

	@Override
	public DirectMailGoodsOrderSender getSenderByOrderId(Integer orderId) {
		return orderSenderManager.getByOrderId(orderId);
	}
	
	@Override
	public DirectMailGoodsOrderSender getSenderPossibleBeDeletedByOrderId(Integer orderId) {
		return orderSenderManager.getPossibleBeDeletedByOrderId(orderId);
	}

	@Autowired
	private DirectMailGoodsOrderReceiverManager orderReceiverManager;

	@Override
	public DirectMailGoodsOrderReceiver getReceiverByOrderId(Integer orderId) {
		return orderReceiverManager.getByOrderId(orderId);
	}
	
	@Override
	public DirectMailGoodsOrderReceiver getReceiverPossibleBeDeletedByOrderId(Integer orderId) {
		return orderReceiverManager.getPossibleBeDeletedByOrderId(orderId);
	}

	@Autowired
	private DirectMailGoodsOrderIdentityManager orderIdentityManager;

	@Override
	public DirectMailGoodsOrderIdentity getIdentityByOrderId(Integer orderId) {
		return orderIdentityManager.getByOrderId(orderId);
	}
	
	@Override
	public DirectMailGoodsOrderIdentity getIdentityPossibleBeDeletedByOrderId(Integer orderId) {
		return orderIdentityManager.getPossibleBeDeletedByOrderId(orderId);
	}
	
	@Override
	public DirectMailGoodsOrderIdentity updateDirectMailGoodsOrderIdentity(DirectMailGoodsOrderIdentity record, String updateUser){
		return orderIdentityManager.edit(record, updateUser);
	}

	@Override
	public DirectMailGoodsOrderReceiver updateReceiver(DirectMailGoodsOrderReceiver receiver, String updateUser) {
		return orderReceiverManager.updateReceiver(receiver, updateUser);
	}

	@Override
	public DirectMailGoodsOrderSender updateSender(DirectMailGoodsOrderSender sender, String updateUser) {
		return orderSenderManager.updateSender(sender, updateUser);
	}

	@Override
	public DirectMailGoodsOrderSender addSender(DirectMailGoodsOrderSender sender, String createUser) {
		return orderSenderManager.addSender(sender, createUser);
	}

	@Override
	public void deleteSender(DirectMailGoodsOrderSender sender, String updateUser) {
		orderSenderManager.deleteSender(sender, updateUser);
	}

	@Override
	public List<DirectMailGoodsOrderShippedRecord> queryShippedRecordByOrderId(Integer orderId) {
		return directMailGoodsOrderShippedRecordManager.queryByOrderId(orderId);
	}

	@Override
	public DirectMailGoodsOrderShippedRecord getShippedRecordById(Integer shippedRecordId) {
		return directMailGoodsOrderShippedRecordManager.getById(shippedRecordId);
	}

	@Override
	public DirectMailGoodsOrderShippedRecord addShippedRecord(DirectMailGoodsOrder order, DirectMailGoodsOrderShippedRecord record, List<Integer> detailIdList, String createUser) {
		return directMailGoodsOrderShippedRecordManager.addShippedRecord(order, record, detailIdList, createUser);
	}

	@Override
	public DirectMailGoodsOrderShippedRecord updateShippedRecord(DirectMailGoodsOrderShippedRecord record, List<Integer> detailIdList, String updateUser) {
		return directMailGoodsOrderShippedRecordManager.updateShippedRecord(record, detailIdList, updateUser);
	}

	@Override
	public void deleteShippedRecord(DirectMailGoodsOrderShippedRecord record, String updateUser) {
		directMailGoodsOrderShippedRecordManager.delete(record, updateUser);
	}
	
	@Autowired
    private DirectMailGoodsOrderAfterSalesManager afterSalesManager;
	
	@Override
	public DirectMailGoodsOrderAfterSales getAfterSalesPossibleBeDeletedByAfterSalesId(Integer afterSalesId) {
		return afterSalesManager.getAfterSalesPossibleBeDeletedByAfterSalesId(afterSalesId);
	}

	@Override
	public Pagination<DirectMailGoodsOrderAfterSales> queryDirectMailGoodsOrderAfterSales(QueryDirectMailGoodsOrderAfterSalesDTO query, Sorting[] sorts, Page page) {
		return afterSalesManager.queryDirectMailGoodsOrderAfterSales(query, sorts, page);
	}

	@Override
	public DirectMailGoodsOrderAfterSales getDirectMailGoodsOrderAfterSalesByOrderId(Integer orderId) {
		return afterSalesManager.getByOrderId(orderId);
	}

	@Override
	public DirectMailGoodsOrderAfterSales getDirectMailGoodsOrderAfterSalesByAfterSalesId(Integer afterSalesId) {
		return afterSalesManager.getDirectMailGoodsOrderAfterSalesByAfterSalesId(afterSalesId);
	}
	
	@Override
	public DirectMailGoodsOrderAfterSales getDirectMailGoodsOrderAfterSalesByAfterSalesIdAndUserId(Integer afterSalesId, Integer userId) {
		return afterSalesManager.getDirectMailGoodsOrderAfterSalesByAfterSalesIdAndUserId(afterSalesId, userId);
	}
	
	@Override
	public Pagination<DirectMailGoodsOrderAfterSales> queryDirectMailGoodsOrderAfterSalesForUser(Integer userId, Page page) {
		return afterSalesManager.queryDirectMailGoodsOrderAfterSalesForUser(userId, page);
	}
	
	@Override
	public DirectMailGoodsOrderAfterSales writeDeliveryNo(DirectMailGoodsOrderAfterSales afterSales, String deliveryNo, String updateUser) throws BizException {
		return afterSalesManager.writeDeliveryNo(afterSales, deliveryNo, updateUser);
	}

	@Autowired
	private DirectMailGoodsOrderAfterSalesRecordManager afterSalesRecordMagager;

	@Override
	public List<DirectMailGoodsOrderAfterSalesRecord> afterSalesRecordList(Integer afterSalesId) {
		return afterSalesRecordMagager.listByAfterSalesId(afterSalesId);
	}
	
	@Override
	public List<DirectMailGoodsOrderAfterSalesRecord> afterSalesRecordListByOrderId(Integer orderId) {
		return afterSalesRecordMagager.listByOrderId(orderId);
	}

	@Autowired
	private DirectMailGoodsOrderCouponManager orderCouponManager;
	
	@Override
	public List<DirectMailGoodsOrderCoupon> queryOrderCouponByOrderId(Integer orderId) {
		return orderCouponManager.queryByOrderId(orderId);
	}

}
